home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / performExtendCosCurve.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  21.1 KB  |  806 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  22 April 1997
  22. //  Author:         sjt
  23. //
  24. //  Description:
  25. //        Initialize the option values.
  26. //
  27. //  Input Arguments:
  28. //      int action
  29. //        0 - just execute the extend curve operation
  30. //        1 - show the option box dialog
  31. //        2 - drag to shelf
  32. //
  33. //  Return Value:
  34. //      None.
  35. //
  36. //    Notes:
  37. //        In the future this can be modified to include extend to object
  38. //
  39. global proc extendCosCurveEnableBoth( string $joinWidget,
  40.                                    string $methodWidget,
  41.                                    string $endWidget,
  42.                                    string $knotsWidget,
  43.                                    string $originalsWidget,
  44.                                    int $priorityEnd )
  45. {
  46.     int $enable;
  47.     if( $priorityEnd ) {
  48.         int $end = `radioButtonGrp -q -select $endWidget`;
  49.         if( 3 == $end ) {
  50.             $enable = 0;
  51.         }
  52.         else {
  53.             $enable = 1;
  54.         }
  55.         radioButtonGrp -edit -enable2 $enable $methodWidget;
  56.         checkBoxGrp -edit -enable $enable $joinWidget;
  57.  
  58.         $enable = `checkBoxGrp -q -value1 $joinWidget`;
  59.         checkBoxGrp -edit -enable $enable $knotsWidget;
  60.         checkBoxGrp -edit -enable $enable $originalsWidget;
  61.     }
  62.     else {
  63.         int $join = `checkBoxGrp -q -value1 $joinWidget`;
  64.         int $method = `radioButtonGrp -q -select $methodWidget`;
  65.         if( $join && (1 == $method)) {
  66.             $enable = 1;
  67.         }
  68.         else {
  69.             $enable = 0;
  70.         }
  71.  
  72.         radioButtonGrp -edit -enable3 $enable $endWidget;
  73.  
  74.         $enable = $join;
  75.         checkBoxGrp -edit -enable $enable $knotsWidget;
  76.         checkBoxGrp -edit -enable $enable $originalsWidget;
  77.     }
  78. }
  79.  
  80. proc setOptionVars(int $forceFactorySettings)
  81. {
  82.     //    ExtendCos Method ( 0 = by distance or 2 = to point ).
  83.     //    Default = 0 = by distance
  84.     //
  85.     if ($forceFactorySettings || !`optionVar -exists extendCosCurveMethod`) {
  86.         optionVar -intValue extendCosCurveMethod 0;
  87.     }
  88.  
  89.     //    Extension Type ( 0 = linear or 1 = cicular or 2 = extrapolate ).
  90.     //    Used only if extend method is 0
  91.     //    Default = 0 = linear
  92.     //
  93.     if ($forceFactorySettings || !`optionVar -exists extendCosCurveType`) {
  94.         optionVar -intValue extendCosCurveType 2;
  95.     }
  96.  
  97.     //    Extend Distance.
  98.     //    Used only if extend method is 0
  99.     //    Default = 1.00
  100.     //
  101.     if ($forceFactorySettings || !`optionVar -exists extendCosCurveDistance`) {
  102.         optionVar -floatValue extendCosCurveDistance 0.1;
  103.     }
  104.  
  105.     //    Extend To Point.
  106.     //    Used only if extend method is 2
  107.     //    Default = 0.0, 0.0, 0.0
  108.     //
  109.     if ($forceFactorySettings || !`optionVar -exists extendCosCurveToPointU`) {
  110.         optionVar -floatValue extendCosCurveToPointU 0.0;
  111.     }
  112.     if ($forceFactorySettings || !`optionVar -exists extendCosCurveToPointV`) {
  113.         optionVar -floatValue extendCosCurveToPointV 0.0;
  114.     }
  115.  
  116.  
  117.     //    Extend Start ( 1 = start or 0 = end, 2 = both )
  118.     //    Default = 0
  119.     //
  120.     if ($forceFactorySettings || !`optionVar -exists extendCosCurveStart`) {
  121.         optionVar -intValue extendCosCurveStart 0;
  122.     }
  123.  
  124.     //    Extend Join ( on = join or off = do not join )
  125.     //    Default = ON
  126.     //
  127.     if ($forceFactorySettings || !`optionVar -exists extendCosCurveJoin`) {
  128.         optionVar -intValue extendCosCurveJoin 1;
  129.     }
  130.  
  131.     //    Extend Remove Multiple Knots ( on = remove or off = do not remove )
  132.     //  Used only when joining 
  133.     //    Default = OFF
  134.     //
  135.     if ($forceFactorySettings ||
  136.         !`optionVar -exists extendCosCurveRemoveMultKnots`) {
  137.         optionVar -intValue extendCosCurveRemoveMultKnots 1;
  138.     }
  139.  
  140.     //  keep original (for in place operations is on-1 or off-0 )
  141.     //    Used only when joining
  142.     /// Default = 0
  143.     //
  144.     if ($forceFactorySettings ||
  145.         !`optionVar -exists extendCosCurveKeepOriginal`) {
  146.         optionVar -intValue extendCosCurveKeepOriginal 0;
  147.     }
  148.  
  149. }
  150.  
  151. //
  152. //  Procedure Name:
  153. //      extendCosCurveSetup
  154. //
  155. //  Description:
  156. //        Update the state of the option box UI to reflect the extend curve
  157. //        option values.
  158. //
  159. //  Input Arguments:
  160. //      parent               - Top level parent layout of the option box UI.
  161. //                             Required so that UI object names can be 
  162. //                             successfully resolved.
  163. //
  164. //        forceFactorySettings - Whether the option values should be set to
  165. //                             default values.
  166. //
  167. //  Return Value:
  168. //      None.
  169. //
  170. global proc extendCosCurveSetup( string $parent,
  171.                                  int $forceFactorySettings,
  172.                                  string $goToTool )
  173. {
  174.     //    Retrieve the option settings
  175.     //
  176.     setOptionVars($forceFactorySettings);
  177.     extendCosCurveToolSetup( $forceFactorySettings, $goToTool );
  178.  
  179.     setParent $parent;
  180.  
  181.     //    Query the optionVar's and set the values into the controls.
  182.  
  183.     //    Extend Method
  184.     //
  185.     int $method = `optionVar -query extendCosCurveMethod`;
  186.     radioButtonGrp -e -sl ($method+1) extendCosCurveMethodBtn;
  187.  
  188.     // extend distance
  189.     floatSliderGrp -edit
  190.         -value `optionVar -query extendCosCurveDistance`
  191.         extendCosCurveDistanceSlider;
  192.  
  193.     // extend type
  194.     int $extendType = `optionVar -query extendCosCurveType`;
  195.     int $realExtendType = $extendType + 1 ;
  196.     radioButtonGrp -edit
  197.         -select $realExtendType
  198.         extendCosCurveTypeBtn;
  199.  
  200.     // extend point
  201.     float $u = `optionVar -q extendCosCurveToPointU`;
  202.     float $v = `optionVar -q extendCosCurveToPointV`;
  203.     floatFieldGrp -e -v1 $u extendCosCurveToPointFloatFieldGrp;
  204.     floatFieldGrp -e -v2 $v extendCosCurveToPointFloatFieldGrp;
  205.  
  206.  
  207.     // extend start and join
  208.     //
  209.     int $join = `optionVar -query extendCosCurveJoin`;
  210.     int $start = `optionVar -query extendCosCurveStart`;
  211.  
  212.     // convert from value to button number
  213.     // ( 1 = start or 0 = end, 2 = both )
  214.     switch( $start ) {
  215.       case 0:
  216.         $start = 2;
  217.         break;
  218.       case 1:
  219.         $start = 1;
  220.         break;
  221.       case 2:
  222.       default:
  223.         $start = 3;
  224.         break;
  225.     }
  226.  
  227.     radioButtonGrp -e
  228.         extendCosCurveMethodBtn;
  229.  
  230.     radioButtonGrp -edit
  231.         -select $start
  232.         extendCosCurveStartBtn;
  233.  
  234.     // Extend join
  235.     //
  236.     checkBoxGrp -edit
  237.         -value1 $join
  238.         extendCosCurveJoinBox;
  239.  
  240.     // Remove Multiple Knots
  241.     //
  242.     checkBoxGrp -edit
  243.         -value1 `optionVar -query extendCosCurveRemoveMultKnots`
  244.         -enable ($join && (3 != $start))
  245.         extendCosCurveRemoveMultKnotsBox;
  246.  
  247.     // Keep original.
  248.     //
  249.     checkBoxGrp -edit
  250.         -value1 `optionVar -query extendCosCurveKeepOriginal`
  251.         -enable ($join && (3 != $start))
  252.         extendCosCurveKeepOriginalBox;
  253.  
  254.     extendCosCurveEnableBoth( "extendCosCurveJoinBox",
  255.                               "extendCosCurveMethodBtn",
  256.                               "extendCosCurveStartBtn",
  257.                               "extendCosCurveRemoveMultKnotsBox",
  258.                               "extendCosCurveKeepOriginalBox",
  259.                               0 );
  260.  
  261.     // Do the visibility here (distance vs. point):
  262.     if( 0 == $method ) {
  263.         tabLayout -e -st extendCosCurveDistance_tab extendCosCurveMethodOptions;
  264.     }
  265.     else {
  266.         tabLayout -e -st extendCosCurveToPoint_tab extendCosCurveMethodOptions;
  267.     }
  268.  
  269.     if( "" != $goToTool ) { 
  270.         checkBoxGrp -e -v1 `scriptCtx -q -euc $goToTool`
  271.           scriptToolExtraWidget;
  272.         checkBoxGrp -e -v2 `scriptCtx -q -lac $goToTool`
  273.           scriptToolExtraWidget;
  274.     }
  275. }
  276.  
  277. //
  278. //  Procedure Name:
  279. //      extendCurveCallback
  280. //
  281. //  Description:
  282. //        Update the option values with the current state of the option box UI.
  283. //
  284. //  Input Arguments:
  285. //      parent - Top level parent layout of the option box UI.  Required so
  286. //               that UI object names can be successfully resolved.
  287. //
  288. //        doIt   - Whether the command should execute.
  289. //
  290. //  Return Value:
  291. //      None.
  292. //
  293. global proc extendCosCurveCallback(string $parent, int $doIt, string $goToTool)
  294. {
  295.     if( "" != $goToTool ) {
  296.         optionVar -iv extendCosCurveEuc `scriptCtx -q -euc $goToTool`;
  297.         optionVar -iv extendCosCurveLac `scriptCtx -q -lac $goToTool`;
  298.     }
  299.     setParent $parent;
  300.  
  301.     //    Set the optionVar's from the control values, and then
  302.     //    perform the command.
  303.  
  304.     //    Extend Method.
  305.     //
  306.     int $method = `radioButtonGrp -query -select extendCosCurveMethodBtn`;
  307.     int $saveMethod = $method - 1 ;
  308.     optionVar -intValue extendCosCurveMethod $saveMethod;
  309.  
  310.     if( $saveMethod == 0 ) {
  311.         // Extend Type
  312.         //
  313.         int $extendType = `radioButtonGrp -query -select extendCosCurveTypeBtn`;
  314.         int $saveExtendType = $extendType - 1 ;
  315.         optionVar -intValue extendCosCurveType $saveExtendType;
  316.  
  317.         // extend distance
  318.         //
  319.         optionVar -floatValue extendCosCurveDistance
  320.             `floatSliderGrp -query -value extendCosCurveDistanceSlider`;
  321.     }
  322.     else {
  323.         //    extend to point.
  324.         //
  325.         float $u = `floatFieldGrp -q -v1 extendCosCurveToPointFloatFieldGrp` ;
  326.         float $v = `floatFieldGrp -q -v2 extendCosCurveToPointFloatFieldGrp` ;
  327.         optionVar -floatValue extendCosCurveToPointU $u ;
  328.         optionVar -floatValue extendCosCurveToPointV $v ;
  329.     }
  330.  
  331.     // Start or end or both
  332.     // ( 1 = start or 0 = end, 2 = both )
  333.     int $start = `radioButtonGrp -query -select extendCosCurveStartBtn`;
  334.  
  335.     // convert from button number to value
  336.     switch( $start ) {
  337.       case 1:
  338.         $start = 1;
  339.         break;
  340.       case 2:
  341.         $start = 0;
  342.         break;
  343.       case 3:
  344.       default:
  345.         $start = 2;
  346.         break;
  347.     }
  348.     optionVar -intValue extendCosCurveStart $start;
  349.  
  350.     // Join
  351.     //
  352.     optionVar -intValue extendCosCurveJoin 
  353.         `checkBoxGrp -query -value1 extendCosCurveJoinBox`;
  354.  
  355.     // Remove Multiple knots
  356.     //
  357.     optionVar -intValue extendCosCurveRemoveMultKnots 
  358.         `checkBoxGrp -query -value1 extendCosCurveRemoveMultKnotsBox`;
  359.  
  360.     // Keep original.
  361.     //
  362.     optionVar -intValue extendCosCurveKeepOriginal
  363.         `checkBoxGrp -query -value1 extendCosCurveKeepOriginalBox`;
  364.  
  365.     if (1 == $doIt) {
  366.         performExtendCosCurve( 0, $goToTool ); 
  367.         string $tmpCmd = "performExtendCosCurve(0, \"" + $goToTool +"\")";
  368.         addToRecentCommandQueue $tmpCmd "Extend Curve On Surface";
  369.     }
  370.     else if( $doIt ) {
  371.         setToolTo $goToTool;
  372.     }
  373. }
  374.  
  375. //
  376. //  Procedure Name:
  377. //      createExtendCosCurveUI
  378. //
  379. //  Description:
  380. //      Fill the contents of the option box for extendCurve command.
  381. //
  382. //  Input Arguments:
  383. //      The name of the parent layout.
  384. //
  385. //  Return Value:
  386. //      None.
  387. //
  388. proc createExtendCosCurveUI(string $parent, int $inTheTool, string $goToTool)
  389. {
  390.     setParent $parent;
  391.  
  392.     string $methodWidget = `radioButtonGrp -label "Extend Method"
  393.         -numberOfRadioButtons 2
  394.         -label1 "Parametric Distance" -da1 0
  395.         -label2 "UV Point" -da2 2
  396.         extendCosCurveMethodBtn`;
  397.  
  398.     tabLayout -tabsVisible false extendCosCurveMethodOptions;
  399.         columnLayout extendCosCurveDistance_tab;
  400.             radioButtonGrp -label "Extension Type"
  401.                 -numberOfRadioButtons 3
  402.                 -label1 "Linear" -da1 0
  403.                 -label2 "Circular" -da2 1
  404.                 -label3 "Extrapolate" -da3 2
  405.                 extendCosCurveTypeBtn;
  406.  
  407.             floatSliderGrp -label "Parametric Distance"
  408.                 -field true
  409.                 -min 0.0
  410.                 -max 100.0
  411.                 extendCosCurveDistanceSlider;
  412.         setParent ..;
  413.  
  414.         columnLayout extendCosCurveToPoint_tab;
  415.             floatFieldGrp -l "UV Point To Extend To"
  416.             -nf 2
  417.             extendCosCurveToPointFloatFieldGrp;
  418.         setParent ..;
  419.     setParent ..;
  420.  
  421.     separator;
  422.  
  423.     string $endWidget = `radioButtonGrp -label "Extend Curve at"
  424.             -numberOfRadioButtons 3
  425.             -label1 "Start" -da1 1 -enable1 1
  426.             -label2 "End" -da2 0 -enable2 1 
  427.             -label3 "Both" -da3 0 -enable3 1
  428.             extendCosCurveStartBtn`;
  429.  
  430.         string $joinWidget = `checkBoxGrp -label ""
  431.             -numberOfCheckBoxes 1
  432.             -label1 "Join to Original"
  433.             extendCosCurveJoinBox`;
  434.  
  435.         string $knotsWidget = `checkBoxGrp -label ""
  436.             -numberOfCheckBoxes 1
  437.             -label1 "Remove Multiple Knots"
  438.             extendCosCurveRemoveMultKnotsBox`;
  439.  
  440.         string $originalsWidget = `checkBoxGrp -label ""
  441.             -numberOfCheckBoxes 1
  442.             -label1 "Keep Original"
  443.             extendCosCurveKeepOriginalBox`;
  444.  
  445.     radioButtonGrp -edit
  446.         -onCommand1 (
  447.                 "tabLayout -e -selectTab extendCosCurveDistance_tab " +
  448.                 "extendCosCurveMethodOptions;"
  449.                 + "extendCosCurveEnableBoth"
  450.                 + " " + $joinWidget
  451.                 + " " + $methodWidget
  452.                 + " " + $endWidget
  453.                 + " " + $knotsWidget
  454.                 + " " + $originalsWidget + " 0;"
  455.             )
  456.         -onCommand2 (
  457.                 "tabLayout -e -selectTab extendCosCurveToPoint_tab " +
  458.                 "extendCosCurveMethodOptions;"
  459.                 + "extendCosCurveEnableBoth"
  460.                 + " " + $joinWidget
  461.                 + " " + $methodWidget
  462.                 + " " + $endWidget
  463.                 + " " + $knotsWidget
  464.                 + " " + $originalsWidget + " 0;"
  465.             )
  466.         $methodWidget;
  467.  
  468.     radioButtonGrp -edit
  469.         -onCommand1 (
  470.                 "extendCosCurveEnableBoth"
  471.                 + " " + $joinWidget
  472.                 + " " + $methodWidget
  473.                 + " " + $endWidget
  474.                 + " " + $knotsWidget
  475.                 + " " + $originalsWidget + " 1;"
  476.             )
  477.         -onCommand2 (
  478.                 "extendCosCurveEnableBoth"
  479.                 + " " + $joinWidget
  480.                 + " " + $methodWidget
  481.                 + " " + $endWidget
  482.                 + " " + $knotsWidget
  483.                 + " " + $originalsWidget + " 1;"
  484.             )
  485.         -onCommand3 (
  486.                 "extendCosCurveEnableBoth"
  487.                 + " " + $joinWidget
  488.                 + " " + $methodWidget
  489.                 + " " + $endWidget
  490.                 + " " + $knotsWidget
  491.                 + " " + $originalsWidget + " 1;"
  492.             )
  493.         $endWidget;
  494.  
  495.     checkBoxGrp -edit
  496.         -onCommand (
  497.                 "extendCosCurveEnableBoth"
  498.                 + " " + $joinWidget
  499.                 + " " + $methodWidget
  500.                 + " " + $endWidget
  501.                 + " " + $knotsWidget
  502.                 + " " + $originalsWidget + " 0;"
  503.             )
  504.         -offCommand (
  505.                 "extendCosCurveEnableBoth"
  506.                 + " " + $joinWidget
  507.                 + " " + $methodWidget
  508.                 + " " + $endWidget
  509.                 + " " + $knotsWidget
  510.                 + " " + $originalsWidget + " 0;"
  511.             )
  512.         $joinWidget;
  513.  
  514.     if( $inTheTool ) {
  515.         separator;
  516.         checkBoxGrp -ncb 2 -l "Tool Behavior"
  517.           -l1 "Exit on Completion"
  518.           -v1 off
  519.           -on1 ("scriptCtx -e -euc true " + $goToTool)
  520.           -of1 ("scriptCtx -e -euc false " + $goToTool)
  521.  
  522.           -l2 "Auto Completion"
  523.           -v2 on
  524.           -on2 ("scriptCtx -e -lac true " + $goToTool)
  525.           -of2 ("scriptCtx -e -lac false " + $goToTool)
  526.           scriptToolExtraWidget;
  527.     }
  528. }
  529.  
  530.  
  531. //
  532. //  Procedure Name:
  533. //      extendCosCurveOptions
  534. //
  535. //  Description:
  536. //        Construct the option box UI.  Involves accessing the standard option
  537. //        box and customizing the UI accordingly.
  538. //
  539. //  Input Arguments:
  540. //      None.
  541. //
  542. //  Return Value:
  543. //      None.
  544. //
  545. proc extendCosCurveOptions( int $inTheTool, string $goToTool )
  546. {
  547.     //    Name of the command for this option box.
  548.     //
  549.     string $commandName = "extendCosCurve";
  550.  
  551.     //    Build the option box actions.
  552.     //
  553.     string $callback = ($commandName + "Callback");
  554.     string $setup = ($commandName + "Setup");
  555.  
  556.     global string $gOptionBoxActionToolItem;
  557.     $gOptionBoxActionToolItem = "modelWithToolExtendCosCurve";
  558.     global string $gOptionBoxActionToolItemCB;
  559.     $gOptionBoxActionToolItemCB = "extendCosCurveToolScript 3";
  560.  
  561.     //  The value returned is the name of the layout to be used as
  562.     //    the parent for the option box UI.
  563.     //
  564.     string $layout = getOptionBox();
  565.     setParent $layout;
  566.     
  567.     //    Pass the command name to the option box.
  568.     //
  569.     //    Any default option box behavior based on the command name is set 
  570.     //    up with this call.  For example, updating the 'Help' menu item with
  571.     //    the name of the command.
  572.     //
  573.     setOptionBoxCommandName($commandName);
  574.     
  575.     //    Activate the default UI template so that the layout of this 
  576.     //    option box is consistent with the layout of the rest of the 
  577.     //    application.
  578.     //
  579.     setUITemplate -pushTemplate DefaultTemplate;
  580.  
  581.     //    Turn on the wait cursor.
  582.     //
  583.     waitCursor -state 1;
  584.  
  585.     //    RECOMMENDATION:  Place the UI in a scroll layout.  If the 
  586.     //    option box window is ever resized such that it's entire 
  587.     //    contents is not visible then the scroll bars provided by the
  588.     //    scroll layout will allow the user to access the hidden UI.
  589.     //
  590.     tabLayout -scr true -tv false;
  591.     
  592.     string $parent = `columnLayout -adjustableColumn 1`;
  593.     
  594.     //  Create the UI for the tab that is initially visible.
  595.     //
  596.     createExtendCosCurveUI($parent, $inTheTool, $goToTool);
  597.  
  598.     //    Turn off the wait cursor.
  599.     //
  600.     waitCursor -state 0;
  601.     
  602.     //    Deactivate the default UI template.
  603.     //
  604.     setUITemplate -popTemplate;
  605.  
  606.     //    Provide more descriptive labels for the buttons.  This is not 
  607.     //    necessary, but in some cases, for example, a button labelled 
  608.     //    'Create' may be more meaningful to the user than one labelled
  609.     //    'Apply'.
  610.     //
  611.     //  Disable those buttons that are not applicable to the option box.
  612.     //
  613.     //    Attach actions to those buttons that are applicable to the option
  614.     //    box.  Note that the 'Close' button has a default action attached 
  615.     //    to it that will hide the window.  If a a custom action is
  616.     //    attached to the 'Close' button then be sure to call the 'hide the
  617.     //    option box' procedure within the custom action so that the option
  618.     //    box is hidden properly.
  619.  
  620.     //    'ExtendCurve' button.
  621.     //
  622.     string $applyBtn = getOptionBoxApplyBtn();
  623.     if( $inTheTool ) {
  624.         button -edit -l "Extend CoS Tool"
  625.             -command ($callback + " " + $parent + " 3 \"" + $goToTool + "\"")
  626.             $applyBtn;
  627.     }
  628.     else {
  629.         button -edit -l "Extend CoS"
  630.             -command ($callback + " " + $parent + " 1 \"" + $goToTool + "\"")
  631.             $applyBtn;
  632.     }
  633.  
  634.     //    'Save' button.
  635.     //
  636.     string $saveBtn = getOptionBoxSaveBtn();
  637.     button -edit 
  638.         -command ($callback + " " + $parent + " 0 \"" +
  639.                   $goToTool + "\"; hideOptionBox")
  640.         $saveBtn;
  641.  
  642.     //    'Reset' button.
  643.     //
  644.     string $resetBtn = getOptionBoxResetBtn();
  645.     button -edit 
  646.         -command ($setup + " " + $parent + " 1 \"" + $goToTool + "\"")
  647.         $resetBtn;
  648.  
  649.     //    Set the option box title.
  650.     //
  651.     if( $inTheTool ) {
  652.         setOptionBoxTitle("Extend Curve on Surface Tool Options");
  653.     }
  654.     else {
  655.         setOptionBoxTitle("Extend Curve on Surface Options");
  656.     }
  657.  
  658.     //    Customize the 'Help' menu item text.
  659.     //
  660.     setOptionBoxHelpTag( "ExtendCurveOnSurface" );
  661.  
  662.     //    Set the current values of the option box.
  663.     //
  664.     eval ($setup + " " + $parent + " 0 \"" + $goToTool + "\"");    
  665.     
  666.     //    Show the option box.
  667.     //
  668.     showOptionBox();
  669. }
  670.  
  671. //
  672. //  Procedure Name:
  673. //      extendCosCurveHelp
  674. //
  675. //  Description:
  676. //        Return a short description about this command.
  677. //
  678. //  Input Arguments:
  679. //      None.
  680. //
  681. //  Return Value:
  682. //      string.
  683. //
  684. proc string extendCosCurveHelp()
  685. {
  686.     return 
  687.     "  Command: extendCurve -cos - extends a curve on surface\n" +
  688.     "Selection: a curve on surface ";
  689. }
  690.  
  691. //
  692. //  Procedure Name:
  693. //      assembleCmd
  694. //
  695. //  Description:
  696. //        Construct the command that will apply the option box values.
  697. //
  698. //  Input Arguments:
  699. //      None.
  700. //
  701. //  Return Value:
  702. //      The extendCurve command string.
  703. //
  704. proc string assembleCmd()
  705. {
  706.     setOptionVars(false);
  707.  
  708.     // get the global history flag value
  709.     int $doHistory = `constructionHistory -q -tgl`;
  710.  
  711.     int $method = `optionVar -query extendCosCurveMethod`;
  712.     int $extendType = `optionVar -query extendCosCurveType`;
  713.     float $distance = `optionVar -query extendCosCurveDistance`;
  714.     float $toPointu = `optionVar -query extendCosCurveToPointU`;
  715.     float $toPointv = `optionVar -query extendCosCurveToPointV`;
  716.  
  717.     int $start = `optionVar -query extendCosCurveStart`;
  718.     int $join = `optionVar -query extendCosCurveJoin`;
  719.     int $removeMultKnots = `optionVar -query extendCosCurveRemoveMultKnots`;
  720.     int $replaceOriginal = !`optionVar -q extendCosCurveKeepOriginal`;
  721.     string $version = "\"2\"";
  722.  
  723.  
  724.     // set up string for preset function call
  725.     //    Note that extendCurvePresetArgList() takes a string array.
  726.     //    The command will look something like:
  727.     //      extendCurvePresetArgList( "2", {"1", "1","0","1",...,"1","1","0"} );
  728.     //
  729.     string $cmd = "extendCurvePresetArgList";
  730.     $cmd = $cmd + "( ";
  731.     $cmd = $cmd + $version;
  732.     $cmd = $cmd + ", { \"1\", \"" ;
  733.     $cmd = $cmd + $doHistory;
  734.     $cmd = $cmd + "\",\"";
  735.     $cmd = $cmd + $method;
  736.     $cmd = $cmd + "\",\"";
  737.     $cmd = $cmd + $extendType;
  738.     $cmd = $cmd + "\",\"";
  739.     $cmd = $cmd + $distance;
  740.     $cmd = $cmd + "\",\"";
  741.     $cmd = $cmd + $toPointu;
  742.     $cmd = $cmd + "\",\"";
  743.     $cmd = $cmd + $toPointv;
  744.     $cmd = $cmd + "\", \"0\", \"";
  745.     $cmd = $cmd + $start;
  746.     $cmd = $cmd + "\",\"";
  747.     $cmd = $cmd + $join;
  748.     $cmd = $cmd + "\",\"";
  749.     $cmd = $cmd + $removeMultKnots;
  750.     $cmd = $cmd + "\",\"";
  751.     $cmd = $cmd + $replaceOriginal;
  752.     $cmd = $cmd + "\" } )";
  753.  
  754.     return $cmd;
  755. }
  756.  
  757. //
  758. //  Procedure Name:
  759. //      performExtendCosCurve
  760. //
  761. //  Description:
  762. //        Perform the optionBoxExample1 command using the corresponding 
  763. //        option values.  This procedure will also show the option box
  764. //        window if necessary as well as construct the command string
  765. //        that will invoke the optionBoxExample1 command with the current
  766. //        option box values.
  767. //
  768. //  Input Arguments:
  769. //      0 - Execute the command.
  770. //      1 - Show the option box dialog.
  771. //      2 - Return the command.
  772. //
  773. //  Return Value:
  774. //      None.
  775. //
  776. global proc string performExtendCosCurve(int $action, string $goToTool )
  777. {
  778.     int $inTheTool = false;
  779.     if( 3 == $action ) {
  780.         $action = 1;
  781.         $inTheTool = true;
  782.     }
  783.  
  784.     string $cmd = "";
  785.     switch ($action) {
  786.  
  787.       case 0:
  788.         setOptionVars(false);
  789.         $cmd = `assembleCmd`;
  790.         eval($cmd);
  791.         break;
  792.  
  793.       case 1:
  794.         extendCosCurveOptions( $inTheTool, $goToTool );
  795.         break;
  796.  
  797.       case 2:
  798.       default:
  799.         setOptionVars (false);
  800.         $cmd = `assembleCmd`;
  801.         break;
  802.     }
  803.     return $cmd;
  804. }
  805.  
  806.